using Godot;
using Godot.Collections;
using System;

using CurrentGame.NPC;
using CurrentGame.GUI.PlaceGrid;

namespace CurrentGame.Levels.DebugScene;


public partial class DebugSceneMain : Node
{
    [Export]
    public Array<ShadeCharacter> ReadyShades { get; set; } = [];

    private SceneSwitch _sceneSwitch;
    private PlaceModeGrid _placeGrid;
    private Player _player;

    public override void _Ready()
    {
        var map = GetNode<NodeReferenceMap>(Constants.NodeRefMapPath);
        _sceneSwitch = map.SceneSwitch;
        _sceneSwitch.SceneStart += Signal_SceneStart;
        _placeGrid = map.PlacementModeGrid;
        _player = map.MainPlayer;

        _player.AttackEnabled = true;
    }

    public override void _ExitTree()
    {
        _sceneSwitch.SceneStart -= Signal_SceneStart;
        _placeGrid.ClearAllShade();
    }

    private void Signal_SceneStart()
    {
        GD.Print("Started");
        foreach (var shade in ReadyShades)
        {
            shade.ActivateFallDetection();
            _placeGrid.AppendReadyShade(shade);
        }
    }
}
